package com.ccdc.lbcmsystem.controller;

import com.ccdc.lbcmsystem.mapper.FeedBackMapper;
import com.ccdc.lbcmsystem.pojo.FeedBack;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
public class InformationController {
    @Autowired
    FeedBackMapper feedBackMapper;
    //信息反馈
    @RequestMapping("/feedBack")
    public String feedBack(){
        return "information/feedBack";
    }

    @RequestMapping("/submitFeedBack")
    @ResponseBody
    public String submitFeedBack(String name, String theme, String content, FeedBack feedBack){
        String msg = "";
        SimpleDateFormat sft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date createTime = new Date();
        String time = sft.format(createTime);
        feedBack.setCreateTime(time);
        feedBack.setName(name);
        feedBack.setTheme(theme);
        feedBack.setContent(content);
        try {
            feedBackMapper.insertFeedBack(feedBack);
            msg = "OK";
            return msg;
        } catch (Exception e) {
            e.printStackTrace();
            msg = "提交失败";
            return msg;
        }

    }
}
